import polymonkey.time.*;

// The Time object used to count deltaTime
Time time;

PFont font;

// the rotation amount
float rot = 0;
float rot2 = 0;

// the speed per second
float speed = 360;
float speed2 = 90;


void setup()
{  
  size(400, 200);

  time = new Time(this);

  // it's just the font
  font = createFont("garamond", 20);
  textFont(font);
  textAlign(LEFT, TOP);

  stroke(0);
  smooth();

}

void draw()
{ 
  background(255);
  
  // draw the first circle
  drawSpinningCircles(100, height/2, rot);

  //draw the second circle  
  drawSpinningCircles(300, height/2, rot2);

  // increase the first rotation amount
  rot += speed * time.getDeltaTime();

  // increase the second rotation amount  
  rot2 += speed2 * time.getDeltaTime();  

  fill(0);
  text("time = " + nf(time.getCountTime(), 1 , 2) + "s", 10, 0);

}



void drawSpinningCircles(float x, float y, float r)
{  
  fill(100);
  text("r = " + nf(r % 360, 1, 1), x-50, y+70);

  pushMatrix();

  translate(x,y);

  fill(180, 32);
  stroke(0, 32);

  ellipse(0, 0, 100, 100);

  line(25, 0, 75, 0);

  rotate(radians(r));

  fill(100);
  stroke(128);
  ellipse(50, 0, 10, 10);  

  popMatrix(); 
}






